package com.xql.framework.action;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * Created by apple on 15/3/22.
 */
public class ActionFactory {
    private static Map<String,ActionMapping> actionMappingMap;
    private static Map<String,Object> actionSupportMap = new HashMap<String, Object>();

    /**
     * add Action to Context
     * @param actionName
     * @param action
     */
    public static void add(String actionName,Object action){
        actionSupportMap.put(actionName,action);
    }

    /**
     * get Action by action name
     * @param name
     * @return
     */
    public static Object getAction(String name){
        return actionSupportMap.get(name);
    }

    /**
     * init actionMapping to Context
     * @param actionMapping
     */
    public static void init(Map<String,ActionMapping> actionMapping){
        actionMappingMap = actionMapping;
    }

    /**
     * get actionMapping by action name
     * @param name
     * @return
     */
    public static ActionMapping getActionMapping(String name){
        return actionMappingMap.get(name);
    }
}
